/*******************************************************************************
 *
 * Copyright (c) 2008-2011 ayound@gmail.com, guwei8576431@gmail.com
 * This program and the accompanying materials
 * are made available under the terms of the GNU GENERAL PUBLIC LICENSE
 * which accompanies this distribution, and is available at
 * http://dev.perl.org/licenses/gpl1.html
 * All rights reserved.
 *
 * Created on 2009-10-25
 *******************************************************************************/

package org.cgtw.scriptprofile.server.manager;

import java.util.ArrayList;
import java.util.List;

import org.cgtw.scriptprofile.server.listener.IProfileDataChangeListener;
import org.cgtw.scriptprofile.server.model.ProfileData;

public class ProfileDataChangeListenerManager {
	private List<IProfileDataChangeListener> listeners = new ArrayList<IProfileDataChangeListener>();

	public static ProfileDataChangeListenerManager instance = null;

	private ProfileDataChangeListenerManager(){}

	public static ProfileDataChangeListenerManager getInstance(){
		if(instance == null){
			instance = new ProfileDataChangeListenerManager();
		}
		return instance;
	}

	public void addListener(IProfileDataChangeListener listener){
		listeners.add(listener);
	}

	public void removeListener(IProfileDataChangeListener listener){
		listeners.remove(listener);
	}

	public void update(){
		for(IProfileDataChangeListener listener : listeners){
			listener.change();
		}
//		ProfileData.clear();
	}

}
